<?php
function pre_request(){
print '<!DOCTYPE html>
<html>
    <head>
		<meta charset="utf-8" />
		<title>sql joiner</title>
		<script type="text/ecmascript" src="/accHestia/gqgrid/js/jquery.min.js"></script>
		<script>
			$(document).ready(function(){
				$("#ibtnsubmit").click(function(){
					$.post(
							"../tools/sql_joiner.php",
							{
								name:"join_req",
								cont:$("#ita1").val(),
							},
							function(data, status) {
								$("#ita2").val(data);
							}
					)
		
				});
			});
		</script>
	</head>
	<body>
		<div id="1">
			<textarea id="ita1" style="width:40%; height:500px;">
			</textarea>
			<textarea id="ita2" style="width:40%; height:500px;">
			</textarea>
		</div>
		<button id="ibtnsubmit">提交</button>
	</body>
        
';
}

if (isset($_POST["name"]) && "join_req" == $_POST["name"]) {
	$a = $_POST["cont"];
	$arr = explode("\n", $a);
	$b = join("\" . \n\"", $arr);
	$b = "\"" . $b . "\"";
	$c = str_replace("\'", "'", $b);
	print $c;
} else {
	pre_request();	
}

?>